<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>Welkom bij WebBooks.com | <%=h yield :title %></title>

    <meta http-equiv="Content-type" content="text/html;charset=iso-8859-1" />

    <script type="text/javascript">
      Rails = {
        'controller' : "<%= @current_controller %>",
        'action' : "<%= @current_action %>"
      }
    </script>
    <%=stylesheet_link_tag :all %>
    <%=javascript_include_tag :all %>
  </head>

  <body>
    <div id="header">
      <div id="logo">WebBooks.com</div>
    </div>
    <div id="topright">
      <div id="account">
        <%= render :partial => 'account/home/topright', :locals => {:user => @account} %>
      </div>

      <div id="shoppingcart">
        <%= render :partial => 'carts/topright', :locals => {:cart => @cart} %>
      </div>
    </div>



    <div id="page">
      <div id="topbar">
        <div class="navigation">
        <%=link_to 'Home', root_path %>
        <%=link_to 'Zoeken', search_path %>
        <%=link_to 'Categorie&euml;n', categories_path %>
        <%=link_to 'Over ons', static_page_path("ons")%>
        <%=link_to 'Contact', static_page_path("test")%>
        </div>

        <div class="search">
          <% form_tag(:controller => '/search', :action => 'set_query') do %>
            <%=text_field_tag :query, nil, :class => 'input' %>
            <%=submit_tag 'Zoeken', :class => 'button' %>
          <% end %>
        </div>
      </div>


      <div id="leftsidebar">

  <h2>Categorie&euml;n</h2>
  <ul id="categories">
    <%=format_search_categories @paginator, @categories, @paginator.category %>
  </ul>

  <div class="search_sidebar">

    <h2>Filters</h2>
    <ul>

      <% if @paginator.category %>
        <li>Categorie: <%=h @paginator.category.name %>  <%=link_to image_tag('bullet_delete.gif'), {:action => 'unset_category', :paginator => @paginator.to_hash} %></li>
      <% end %>

      <% if @paginator.query %>
        <li>Titel &amp; beschrijving: <%=h @paginator.query %>  <%=link_to image_tag('bullet_delete.gif'), {:action => 'unset_query', :paginator => @paginator.to_hash} %></li>
      <% end %>

      <% if @paginator.min_price and @paginator.max_price %>
        <li>Prijs: tussen <%=format_price @paginator.min_price %> en <%=format_price @paginator.max_price %> <%=link_to image_tag('bullet_delete.gif'), {:action => 'unset_price_range', :paginator => @paginator.to_hash} %></li>
      <% elsif @paginator.max_price %>
        <li>Prijs: minder dan <%=format_price @paginator.max_price %>  <%=link_to image_tag('bullet_delete.gif'), {:action => 'unset_price_range', :paginator => @paginator.to_hash} %></li>
      <% elsif @paginator.min_price %>
        <li>Prijs: meer dan: <%=format_price @paginator.min_price %>  <%=link_to image_tag('bullet_delete.gif'), {:action => 'unset_price_range', :paginator => @paginator.to_hash} %></li>
      <% end %>

      <% @paginator.attributes_filters.each do |f| %>
        <li><%=h f[:attribute].name %>: <%=h f[:filter] %> <%=link_to image_tag('bullet_delete.gif'), {:action => 'unset_attribute_filter', :attribute_id => f[:attribute].id, :paginator => @paginator.to_hash} %></li>
      <%  end %>

        <% if !@paginator.category and !@paginator.query and !@paginator.min_price and !@paginator.max_price and @paginator.attributes_filters.size == 0 %>
        <li>Geen filters gevonden</li>
        <% end %>
    </ul>

    <h2>Zoeken</h2>
    <h3>Handmatig</h3>
    <% form_tag(:action => 'set_filter', :paginator => @paginator.to_hash) do %>
      <%=select_tag :attribute_id, options_for_select( [['Titel & beschrijving', -1], ['- ' * 15, 0]] + @searchable_attributes.collect{|attribute| [h(attribute.name), attribute.id]} ) %>
      <%=text_field_tag :filter %>
      <%=submit_tag 'Toepassen' %>
    <% end %>

    <div id="autocomplete" class="autocomplete"></div>

    <script type="text/javascript">
      new Ajax.Autocompleter('filter', 'autocomplete', '<%=url_for(:action => :autocomplete) %>');
    </script>


    <h3>Prijs</h3>
    <div>
      <%# Zie javascripts/slider_price.js voor meer informatie over de slider. %>
      <div class="price_slider" id="track">
        <div class="active_track" id="active_track"></div>
        <div id="handle_wrapper1" class="handle_wrapper"><div class="handle" id="handle1">?</div></div>
        <div id="handle_wrapper2" class="handle_wrapper"><div class="handle" id="handle2">?</div></div>
      </div>



      <% form_tag({:action => 'set_price_range', :paginator => @paginator.to_hash}) do %>
      <%=text_field_tag :min_price, @paginator.min_price %>
      <%=text_field_tag :max_price, @paginator.max_price %>
      <%=submit_tag 'Filter op prijs' %>
      <% end %>


    </div>

    <% @paginator.recommended_attribute_filters(4, 15).each do |attribute_filter| %>

      <h3><%=h attribute_filter[:attribute].name %></h3>
      <ul>
        <% attribute_filter[:filters].each do |filter| %>
          <li><%=h filter[:value] %> (<%=filter[:results] %>) <%=link_to image_tag('bullet_add.gif'), {:action => 'set_attribute_filter', :attribute_id => attribute_filter[:attribute], :filter => filter[:value], :paginator => @paginator.to_hash} %></li>
        <% end %>
      </ul>

    <% end %>

  </div>
      </div>

      <div id="rightsidebar">

          <% unless @top_products.blank? %>
            <h2>Aangeraden</h2>
            <%  @top_products.each_index do |i|%>
              <%=image_tag @top_products[i].image.resize(75, 75, true), :width => 75, :height => 75 %>
              <p>
                <%=i+1 %>. <%=link_to h(truncate(@top_products[i].name)), product_path(@top_products[i]) %>
              </p>
            <%end%>
          <%end%>


        <% unless @viewed_products.blank? %>
          <h2>Bekeken</h2>
          <%=render :partial => 'products/sidebar', :locals => {:products => @viewed_products} %>
        <% end %>

      </div>

      <div id="contents" class="<%= @current_controller %> <%= @current_controller %>-<%= @current_action %>">
        <h1><%=h yield :title %></h1>

        <% if flash[:notice] %>
          <div class="notice"><%= flash[:notice] %></div>
        <% end %>

        <%# De width: 98% is om een bug in IE (alle versies) te voorkomen waarbij de tabel de breedte van het hele scherm krijgen i.p.v. de breedte van #contents. %>
        <div style="width: 98%;">

<% if @paginator.find_items.size == 0 %>

<div class="notice">Er zijn geen resultaten gevonden, waarschijnlijk zijn de filters die u heeft ingesteld te streng.
Klik onder het kopje 'filters' op het icoontje <%=image_tag('bullet_delete.gif')%> om een filter te verwijderen.</div>

<% else %>
<p>
  Sorteer op:
<%=paginator_column 'Titel', :name, @paginator %> |
<%=paginator_column 'Prijs', :price, @paginator %> |
<%=paginator_column 'Toegevoegd', :created_at, @paginator %>
</p>

<p>
  <%=@paginator.count_items %> producten gevonden.
</p>

<%=render :partial => 'products/list', :locals => {:products => @paginator.find_items} %>

<%= paginator_pages @paginator %>
<% end %>





        </div>

      </div>


      <div id="policy"><%= link_to 'Privacy Policy',static_page_path("policy")%>
        <%= link_to 'Algemene Voorwaarden',static_page_path("voorwaarden")%>
        <div id="copyright"><%= link_to 'Copyright',static_page_path("copyright")%> 2010 WebBooks.com</div>
      </div>

    </div>
  </body>
</html>






